package com.jerry.hm.algorithm.binarysearch;

/**
 * 线程查找
 *
 * @author Jerry
 * @since 2024/9/28 18:47
 */
public class LinearSearch {

    /**
     * 线性查找
     *
     * @param arr    待查找的升序数组
     * @param target 待查找的目标
     * @return 找到返回索引，否则返回-1
     */
    public static int linearSearch(int[] arr, int target) {
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == target) {
                return i;
            }
        }
        return -1;
    }
}
